@extends('layouts.mobile_main')

@section('title', '意见反馈')

@section('resources')
    @parent
    <link rel="stylesheet" href="{{ env('CSS_DOMAIN') }}/css/public.css?v={{env('CSS_VERSION')}}">
    <script src="{{ env('JS_DOMAIN') }}/js/adaptation.js?v={{env('JS_VERSION')}}"></script>
    <style>
        textarea{
            width: 9rem;
            height: 5rem;
            background:#fff;
            margin: 1rem 0;
            font-size: 0.38rem;
            padding: 0.3rem 0.4rem;
            border: 1px solid #9955c6;
        }
        section p{
            position: absolute;
            bottom: 1.4rem;
            right: 0.8rem;
        }
    </style>
@endsection

@section('content')
<header class="pay_sure oh" style="background-color: #fff;">
    <a class="fl" href="javascript:history.go(-1);">
        <img class="fl" src="{{env('IMAGE_DOMAIN')}}/images/back_p.png?v={{env('IMAGE_VERSION')}}" alt="">
    </a>
    <span class="fl co_violet fz_48">意见反馈</span>
</header>
<section class="tc pr">
    <textarea name="content" id="" placeholder="请输入您的宝贵意见，谢谢~" onkeyup="xian()"></textarea>
    <p class="oh">
        <span class="fz_34 fl textnum co_gray">0</span>
        <span class="fz_34 fl co_gray">/500</span>
    </p>
    <button class="fz_48 me_out fl" id="submit">提交</button>
</section>
@endsection

@section('scriptResources')
    @parent
    <script>
	    window.onresize=function(){
		    pagesp();
	    }
	    function xian(){
       		var textnum=$("textarea").val().length;
       		$(".textnum").html(textnum);
       		if(textnum>500){
       			textnum=500;
       			$("textarea").val($("textarea").val().substring(0,500));
       			$(".textnum").html(textnum);
       		}
       	}
       	$(function(){
       		var paysu_outer_h=$(window).height();
       		$(".paysu_outer").css({"min-height":paysu_outer_h});
       	})
       	$("#submit").click(function(){
       	    var content = $("textarea").val();
            $.ajax({
                url :"/mobile/mycenter/suggestion/add",
                type:'POST',
                data : {'content':content},
                dataType:'json',
                async:false,
                success:function(data){
                    if (data.status == "success") {
                         alert("提交成功");
                         window.location.href = '/mobile/mycenter/more';
                    } else {
                        alert(data.message);
                    }
                }
            });
        });
    </script>
@endsection